#pragma once
#include "Singleton.hpp"
#include <RedisConpool.hpp>
#include <hiredis/hiredis.h>
#include <memory>
#include <string>
class RedisMgr : public Singleton<RedisMgr> {
  friend class Singleton<RedisMgr>;

private:
  RedisMgr();
  std::unique_ptr<RedisConPool> _pool;

public:
  ~RedisMgr();
  bool Get(const std::string &key, std::string &value);
  bool Set(const std::string &key, std::string &value);
  bool LPush(const std::string &key, const std::string &value);
  bool LPop(const std::string &key, std::string &value);
  bool RPush(const std::string &key, const std::string &value);
  bool RPop(const std::string &key, std::string &value);
  bool HSet(const std::string &key, std::string &hkey,
            const std::string &value);
  bool HSet(const char *key, const char *hkey, const char *hvalue,
            size_t hvaluelen);
  bool HDel(const std::string &key, const std::string &filed);
  std::string HGet(const std::string &key, const std::string &hkey);
  bool Del(const std::string &key);

  bool ExistKey(const std::string &key);
  void Close();
};